<template>
	<view class="review">
		<view class="tab">
			<view :class="item.id == formData.noteId?'tab-list active':'tab-list'" @click="tabClick(item)"
				v-for="item in teacher">{{item.teacherName}}</view>
		</view>
		<view class="view-radio">
			<uni-section v-for="item in titleList" :title="item.text" type="line">
				<view class="uni-px-5 uni-pb-5">
					<uni-data-checkbox v-model="formData[item.file]" :localdata="review"></uni-data-checkbox>
				</view>
			</uni-section>
			<uni-section title="教案优势" type="line">
				<view class="uni-px-5 uni-pb-5">
					<uni-easyinput v-model="formData.activity_advantage" type="textarea"
						placeholder="请输入内容"></uni-easyinput>
				</view>
			</uni-section>
			<uni-section title="建议" type="line">
				<view class="uni-px-5 uni-pb-5">
					<uni-easyinput v-model="formData.activity_comment" type="textarea"
						placeholder="请输入内容"></uni-easyinput>
				</view>
			</uni-section>
			<view class="btn" v-if="$store.state.user.roles"><button @click="saveCheckNoteData"
					type="primary">保存</button></view>
		</view>
	</view>
</template>

<script>
	import {
		saveCheckNote,
		getFindCheckNote
	} from "@/api/home"
	export default {
		props: {
			activeId: {
				type: String,
				default: ""
			}
		},
		watch: {
			activeId: {
				handler(val) {
					this.formData.activity_id = val
				},
				immediate: true,
				deep: true
			}
		},
		data() {
			return {
				formData: {
					activity_id: "",
					noteId: "",
					activity_comment: "",
					activity_advantage: "",
					cours: "",
					scheduling: "",
					element_analysis: "",
					student_analysis: "",
					teaching_important_points: "",
					spare_time: "",
					teaching_preparation: "",
					teaching_intention: "",
					job_design: "",
					blackboard_design: "",
					teaching_reflection: "",
					deviceId: this.$store.state.user.deviceId,
					havepic: "0"
				},
				review: [{
						text: '优',
						value: 1
					},
					{
						text: '良',
						value: 2
					},
					{
						text: '中',
						value: 3
					},
					{
						text: '差',
						value: 4
					},
				],
				titleList: [{
						text: "教程分析",
						file: "cours"
					},
					{
						text: "教学进度安排",
						file: "scheduling"
					},
					{
						text: "单元分析",
						file: "element_analysis"
					},
					{
						text: "学情分析次数",
						file: "student_analysis"
					},
					{
						text: "教学目标重难点",
						file: "teaching_important_points"
					},
					{
						text: "分课时备课",
						file: "spare_time"
					},
					{
						text: "教学且准备",
						file: "teaching_preparation"
					},
					{
						text: "教学意图",
						file: "teaching_intention"
					},
					{
						text: "作业设计",
						file: "job_design"
					},
					{
						text: "板书设计",
						file: "blackboard_design"
					},
					{
						text: "课后反思",
						file: "teaching_reflection"
					},
				],
				teacher: [],
			}
		},
		created() {
			// this.getByCheckInfoDetailsData();
			this.getFindCheckNoteData();
		},
		methods: {
			//保存检查抽查
			saveCheckNoteData() {
				saveCheckNote(this.formData).then(res => {
					if (res.status === 0) {
						this.getFindCheckNoteData();
					}
				})
			},
			//获取详情
			// getByCheckInfoDetailsData(){
			//     getByCheckInfoDetails({teachingID:this.formData.activity_id,deviceId:this.formData.deviceId}).then(res=>{
			//         console.log(res)
			//         let teachersName= res.checkDetails.teachersNames.split(",");
			//         let teachers= res.checkDetails.teachers.split(",");
			//         this.formData.teacher_id = teachers[0];
			//         for (let i=0;i<teachersName.length;i++){
			//             this.teacher.push({value:teachers[i],text:teachersName[i]});
			//         }
			//     })
			// },
			getFindCheckNoteData() {
				getFindCheckNote({
					activityId: this.formData.activity_id,
					deviceId: this.formData.deviceId
				}).then(res => {
					this.teacher = res.checkNotes;
					this.formData.noteId = res.checkNotes[0]["id"];
					this.formData.activity_advantage = res.checkNotes[0]["activity_advantage"];
					this.formData.activity_comment = res.checkNotes[0]["activity_comment"];
					this.formData.cours = res.checkNotes[0]["cours"];
					this.formData.scheduling = res.checkNotes[0]["scheduling"];
					this.formData.element_analysis = res.checkNotes[0]["element_analysis"];
					this.formData.student_analysis = res.checkNotes[0]["student_analysis"];
					this.formData.teaching_important_points = res.checkNotes[0]["teaching_important_points"];
					this.formData.spare_time = res.checkNotes[0]["spare_time"];
					this.formData.teaching_preparation = res.checkNotes[0]["teaching_preparation"];
					this.formData.teaching_intention = res.checkNotes[0]["teaching_intention"];
					this.formData.job_design = res.checkNotes[0]["job_design"];
					this.formData.blackboard_design = res.checkNotes[0]["blackboard_design"];
					this.formData.teaching_reflection = res.checkNotes[0]["teaching_reflection"];
					this.formData.teaching_intention = res.checkNotes[0]["teaching_intention"];
					this.formData.teaching_intention = res.checkNotes[0]["teaching_intention"];
					this.formData.teaching_intention = res.checkNotes[0]["teaching_intention"];
				})
			},
			tabClick(data) {
				this.formData.noteId = data["id"];
				this.formData.activity_advantage = data["activity_advantage"];
				this.formData.activity_comment = data["activity_comment"];
				this.formData.cours = data["cours"];
				this.formData.scheduling = data["scheduling"];
				this.formData.element_analysis = data["element_analysis"];
				this.formData.student_analysis = data["student_analysis"];
				this.formData.teaching_important_points = data["teaching_important_points"];
				this.formData.spare_time = data["spare_time"];
				this.formData.teaching_preparation = data["teaching_preparation"];
				this.formData.teaching_intention = data["teaching_intention"];
				this.formData.job_design = data["job_design"];
				this.formData.blackboard_design = data["blackboard_design"];
				this.formData.teaching_reflection = data["teaching_reflection"];
				this.formData.teaching_intention = data["teaching_intention"];
				this.formData.teaching_intention = data["teaching_intention"];
				this.formData.teaching_intention = data["teaching_intention"];
			}
		}
	}
</script>

<style lang="scss">
	.review {
		padding: 10px;

		.tab {
			background: #fff;
			display: flex;
			align-items: center;
			margin: -10px -10px 5px;
			border-top: 1px solid #eee;
			justify-content: space-evenly;
			overflow-x: scroll;

			.tab-list {
				padding: 10px 5px;
			}

			.active {
				border-bottom: 1px solid #3c96f3;
				color: #3c96f3;
			}
		}

		.view-radio {
			padding: 10px;
			background: #fff;
			border-radius: 10px;

			.btn {
				margin-top: 10px;
			}
		}
	}
</style>